<?php
/**
 * @link https://www.kancloud.cn/cleverstone/ymb2
 * @copyright Copyright (c) 2020 Yii Manager Software LLC
 */

namespace builder\form\util\control\xselect;

/**
 * 下拉树
 * @desc 该控件用于补充select2相关控件的不足
 * @author cleverstone
 * @since ym2.0
 * @see https://gitee.com/maplemei/xm-select
 */
class XselectTree extends Xselect
{
    /**
     * 初始化选项
     */
    protected function init()
    {
        $this->options['control'] = 'xselect_tree';
        $this->options['pluginOptions']['tree'] = [
            'show' => true, //是否显示树状结构
        ];
    }

    /**
     * 是否展示三角图标
     * @param boolean $showFolderIcon
     * @return $this
     */
    public function showFolderIcon($showFolderIcon)
    {
        $this->options['pluginOptions']['tree']['showFolderIcon'] = $showFolderIcon;
        return $this;
    }

    /**
     * 是否显示虚线
     * @param boolean $showLine
     * @return $this
     */
    public function showLine($showLine)
    {
        $this->options['pluginOptions']['tree']['showLine'] = $showLine;
        return $this;
    }

    /**
     * 间距
     * @param int $indent
     * @return $this
     */
    public function indent($indent)
    {
        $this->options['pluginOptions']['tree']['indent'] = $indent;
        return $this;
    }

    /**
     * 默认展开节点的数组, 为 true 时, 展开所有节点
     * @param boolean|array $expandedKeys
     * @return $this
     */
    public function expandedKeys($expandedKeys)
    {
        $this->options['pluginOptions']['tree']['expandedKeys'] = $expandedKeys;
        return $this;
    }

    /**
     * 是否严格遵守父子模式
     * @param boolean $strict
     * @return $this
     */
    public function strict($strict)
    {
        $this->options['pluginOptions']['tree']['strict'] = $strict;
        return $this;
    }

    /**
     * 是否开启极简模式
     * @param boolean $simple
     * @return $this
     */
    public function simple($simple)
    {
        $this->options['pluginOptions']['tree']['simple'] = $simple;
        return $this;
    }

    /**
     * 点击节点是否展开
     * @param boolean $clickExpand
     * @return $this
     */
    public function clickExpand($clickExpand)
    {
        $this->options['pluginOptions']['tree']['clickExpand'] = $clickExpand;
        return $this;
    }

    /**
     * 点击节点是否选中
     * @param boolean $clickCheck
     * @return $this
     */
    public function clickCheck($clickCheck)
    {
        $this->options['pluginOptions']['tree']['clickCheck'] = $clickCheck;
        return $this;
    }
}